<template>
	<view class="main">
		<input type="text" v-model="code" class="input" placeholder="请输入兑换码">
		<view class="btn flex_center_align" @click="exchange">兑换</view>
		<view class="text fz13 c666">
			<p>1、小竹兑换码，仅限领取ID（手机号）使用，每笔订单限用一次，不能与其他优惠同时享受。</p>
			<p> 2、使用小竹兑换码支付的订单，用小竹兑换码抵扣的金额不能开具发票。</p>
			<p>3、本规则由本公司依据国家相关法律法规及规章制度予以解释 。</p>
		</view>
	</view>
</template>

<script>
import { checkCode } from '@/api/my.js'
export default {
	data() {
		return {
			code: '',
		};
	},
	methods: {
		exchange() {
			if (this.code == '') {
				this.$tools.showToast('请填写兑换码');
				return
			}
			checkCode({
				code: this.code
			}).then(res => {
				if (res.code == 1) {
					uni.navigateTo({
						url: '/pages/my/vip/exchangeResult?status=1&type=' + res.data.type
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/vip/exchangeResult?status=2'
					})
				}
			})
		}
	},
	onShow() {
		this.code = ''
	},
}
</script>

<style lang="scss" scoped>
.main {
	height: 100%;
	width: 100%;
	overflow-y: auto;

	.input {
		padding: 0 40rpx;
		margin: 0 auto;
		margin-top: 100rpx;
		width: 630rpx;
		height: 90rpx;
		background: #FFFFFF;
		border-radius: 131rpx;
		border: 1rpx solid #CCCCCC;
		box-sizing: border-box;
	}

	.btn {
		margin: 0 auto;
		margin-top: 90rpx;
		width: 630rpx;
		height: 90rpx;
		background: #1C87F3;
		color: #fff;
		font-size: 40rpx;
		border-radius: 45px;
	}

	.text {
		margin: 0 auto;
		margin-top: 140rpx;
		width: 600rpx;
		height: 252rpx;
		line-height: 40rpx;
	}
}
</style>
